package com.guacun.service;

import com.guacun.controller.StudentController;
import com.guacun.dao.StudentDao;
import com.guacun.model.Student;

import java.util.Scanner;

public class StudentService {
    private static Scanner scanner = new Scanner(System.in);
    private StudentDao studentDao = new StudentDao();

    //添加
    public int addStudent(Student student) {
        Student[] list = {student};
        int flag = studentDao.add(list);
        return flag;
    }
//删除
    public int deleteStudent(int id) {
        return studentDao.deletestudent(id);
    }

    public int updateStudent(int id) {
        System.out.println("请输入要修改的学生姓名:");
        String nname = scanner.next();
        System.out.println("请输入学生年龄:");
        int age = scanner.nextInt();
        System.out.println("请输入学生生日:");
        String nbrithday = scanner.next();
        return  studentDao.updatestudentdao(new Student(id,nname,age,nbrithday));
    }

    public int selectStudent() {

        int i = studentDao.selectall();
        return i;
    }
    public Student selectStudentbyid(int id) {
        Student selectallbyid = studentDao.selectallbyid(id);
        System.out.println("2"+selectallbyid);
        return selectallbyid;
    }
}
